﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DataTransferObject;
namespace _5ChickDeal.UserControl
{
    public partial class AcountDetails : System.Web.UI.UserControl
    {
        DataClassesDataContext db;
        protected void Page_Load(object sender, EventArgs e)
        {
            
            if (Session["user"] == null)
            {
                Response.Redirect("~/Default.aspx");

            }
            else if(!IsPostBack)
            {
                KhachHang kh = (KhachHang)Session["user"];
                TextBoxEmail.Text = kh.email;
                TextBoxHoTen.Text = kh.hoten;
                Label1.Text = kh.id.ToString();
                TextBoxSoDienThoai.Text = kh.dienthoai;
                
                
                
            }

            
        }

        protected void LinkButtonUpDate_Click(object sender, EventArgs e)
        {
            db = new DataClassesDataContext();
            KhachHang k = (KhachHang)Session["user"];
            KhachHang kh = db.KhachHangs.Single(a => a.id == k.id);
            kh.hoten = TextBoxHoTen.Text;
            kh.dienthoai =TextBoxSoDienThoai.Text;
            db.SubmitChanges();
            Session["user"] = kh;
            Label2.Text = "Cập nhật thành công";

            
        }

       

      

       
    }
}